package 课后作业1.Test2;

import java.util.Objects;

/*创建一个ArrayList<Employee>，在ArrayList<Employee>中增加三个员工，基本信息如下：
 * 工号  姓名   年龄   工资
 * 1     zhangsan  18    3000
 * 2     lisi      25    3500
 * 3     wangwu   22     3200
 * 2) 在lisi之前插入一个员工，信息为：姓名：zhaoliu，年龄：24，工资3300
 * 3) 删除wangwu 的信息
 * 4) 利用for 循环遍历，打印List 中所有工人的信息
 * 5) 利用迭代遍历，对List 中所有的工人调用work 方法。
 * 6) 为Employee 类重写equals方法和hashCode()方法，当员工工号、员工姓名相等时候才返回true*/
public class Employee {
    private int employeeNum;
    private String name;
    private int age;
    private double salary;

    public Employee() {
    }

    public Employee(int employeeNum, String name, int age, double salary) {
        this.employeeNum = employeeNum;
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    public int getEmployeeNum() {
        return employeeNum;
    }

    public void setEmployeeNum(int employeeNum) {
        this.employeeNum = employeeNum;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Employee)) return false;
        Employee employee = (Employee) o;
        return getEmployeeNum() == employee.getEmployeeNum() && getName().equals(employee.getName());
    }

    @Override
    public int hashCode() {
        return Objects.hash(employeeNum, name, age, salary);
    }

    public void work() {
        System.out.println(this.getName() + "在工作");
    }
}
